package com.aspose.cells.b.a;

import java.util.UUID;

public final class zh implements Comparable<zh> {
   public static final zh a = new zh();
   private int b;
   private short c;
   private short d;
   private byte e;
   private byte f;
   private byte g;
   private byte h;
   private byte i;
   private byte j;
   private byte k;
   private byte l;

   public String a(String var1, com.aspose.cells.b.a.c.za var2) {
      return this.a(var1);
   }

   public zh(byte[] var1) {
      if (var1 == null) {
         throw new NullPointerException("b");
      } else if (var1.length != 16) {
         throw new IllegalArgumentException("Guid array ctor: b length should be 16.");
      } else {
         this.b = var1[3] << 24 | (var1[2] & 255) << 16 | (var1[1] & 255) << 8 | var1[0] & 255;
         this.c = (short)(var1[5] << 8 | var1[4] & 255);
         this.d = (short)(var1[7] << 8 | var1[6] & 255);
         this.e = var1[8];
         this.f = var1[9];
         this.g = var1[10];
         this.h = var1[11];
         this.i = var1[12];
         this.j = var1[13];
         this.k = var1[14];
         this.l = var1[15];
      }
   }

   public zh() {
      this.b = 0;
      this.c = 0;
      this.d = 0;
      this.e = 0;
      this.f = 0;
      this.g = 0;
      this.h = 0;
      this.i = 0;
      this.j = 0;
      this.k = 0;
      this.l = 0;
   }

   public static zh a(UUID var0) {
      long var1 = var0.getMostSignificantBits();
      long var3 = var0.getLeastSignificantBits();
      return new zh(var1, var3);
   }

   public zh(long var1, long var3) {
      this.b = (int)(var1 >> 32);
      this.c = (short)((int)(var1 >> 16));
      this.d = (short)((int)var1);
      this.e = (byte)((int)(var3 >> 56));
      this.f = (byte)((int)(var3 >> 48));
      this.g = (byte)((int)(var3 >> 40));
      this.h = (byte)((int)(var3 >> 32));
      this.i = (byte)((int)(var3 >> 24));
      this.j = (byte)((int)(var3 >> 16));
      this.k = (byte)((int)(var3 >> 8));
      this.l = (byte)((int)var3);
   }

   public zh(String var1) {
      if (var1 == null) {
         throw new NullPointerException("g");
      } else {
         byte var2 = 0;
         int[] var6 = new int[]{0};

         try {
            if (var1.indexOf(45, 0) < 0) {
               throw new IllegalStateException("Unsupported Guid Format: " + var1);
            } else {
               String var7 = var1.trim();
               if (var7.charAt(0) == '{') {
                  if (var7.length() != 38 || var7.charAt(37) != '}') {
                     throw new IllegalStateException("Wrong Guid format sting length: " + var1);
                  }

                  var2 = 1;
               } else if (var7.charAt(0) == '(') {
                  if (var7.length() != 38 || var7.charAt(37) != ')') {
                     throw new IllegalStateException("Wrong Guid format sting length: " + var1);
                  }

                  var2 = 1;
               } else if (var7.length() != 36) {
                  throw new IllegalStateException("Wrong Guid format sting length: " + var1);
               }

               if (var7.charAt(8 + var2) == '-' && var7.charAt(13 + var2) == '-' && var7.charAt(18 + var2) == '-' && var7.charAt(23 + var2) == '-') {
                  var6[0] = var2;
                  this.b = a(var7, var6, 8);
                  ++var6[0];
                  this.c = (short)a(var7, var6, 4);
                  ++var6[0];
                  this.d = (short)a(var7, var6, 4);
                  ++var6[0];
                  int var3 = a(var7, var6, 4);
                  ++var6[0];
                  int var9 = var6[0];
                  long var4 = zj.a(var7, 16, 8192, var6);
                  if (var6[0] - var9 != 12) {
                     throw new IllegalStateException("Wrong Guid format sting length: " + var1);
                  } else {
                     this.e = (byte)(var3 >> 8);
                     this.f = (byte)var3;
                     var3 = (int)(var4 >> 32);
                     this.g = (byte)(var3 >> 8);
                     this.h = (byte)var3;
                     var3 = (int)var4;
                     this.i = (byte)(var3 >> 24);
                     this.j = (byte)(var3 >> 16);
                     this.k = (byte)(var3 >> 8);
                     this.l = (byte)var3;
                  }
               } else {
                  throw new IllegalStateException("Wrong format: missed or misplaced dashes: " + var1);
               }
            }
         } catch (IndexOutOfBoundsException var8) {
            throw new IllegalStateException("Format_GuidUnrecognized");
         }
      }
   }

   private static int a(String var0, int[] var1, int var2) {
      int var3 = var1[0];
      int var4 = (int)zj.a(var0, 16, 8192, var1);
      if (var1[0] - var3 != var2) {
         throw new IllegalStateException("Wrong Guid Format: Invalid Char: " + var0);
      } else {
         return var4;
      }
   }

   public byte[] a() {
      byte[] var1 = new byte[]{(byte)this.b, (byte)(this.b >> 8), (byte)(this.b >> 16), (byte)(this.b >> 24), (byte)this.c, (byte)(this.c >> 8), (byte)this.d, (byte)(this.d >> 8), this.e, this.f, this.g, this.h, this.i, this.j, this.k, this.l};
      return var1;
   }

   public String toString() {
      return this.a("D");
   }

   public int hashCode() {
      return this.b ^ ((this.c & '\uffff') << 16 | this.d & '\uffff') ^ ((this.g & 255) << 24 | this.l & 255);
   }

   public boolean equals(Object obj) {
      return obj instanceof zh && a(this, (zh)obj);
   }

   public static boolean a(zh var0, zh var1) {
      if (var0 == var1) {
         return true;
      } else if (var0 != null && var1 != null) {
         if (var0.b != var1.b) {
            return false;
         } else if (var0.c != var1.c) {
            return false;
         } else if (var0.d != var1.d) {
            return false;
         } else if (var0.e != var1.e) {
            return false;
         } else if (var0.f != var1.f) {
            return false;
         } else if (var0.g != var1.g) {
            return false;
         } else if (var0.h != var1.h) {
            return false;
         } else if (var0.i != var1.i) {
            return false;
         } else if (var0.j != var1.j) {
            return false;
         } else if (var0.k != var1.k) {
            return false;
         } else {
            return var0.l == var1.l;
         }
      } else {
         return false;
      }
   }

   private int a(long var1, long var3) {
      return var1 < var3 ? -1 : 1;
   }

   public int a(zh var1) {
      if (var1 == null) {
         return 1;
      } else if (var1.b != this.b) {
         return this.a((long)this.b, (long)var1.b);
      } else if (var1.c != this.c) {
         return this.a((long)this.c, (long)var1.c);
      } else if (var1.d != this.d) {
         return this.a((long)this.d, (long)var1.d);
      } else if (var1.e != this.e) {
         return this.a((long)this.e, (long)var1.e);
      } else if (var1.f != this.f) {
         return this.a((long)this.f, (long)var1.f);
      } else if (var1.g != this.g) {
         return this.a((long)this.g, (long)var1.g);
      } else if (var1.h != this.h) {
         return this.a((long)this.h, (long)var1.h);
      } else if (var1.i != this.i) {
         return this.a((long)this.i, (long)var1.i);
      } else if (var1.j != this.j) {
         return this.a((long)this.j, (long)var1.j);
      } else if (var1.k != this.k) {
         return this.a((long)this.k, (long)var1.k);
      } else {
         return var1.l != this.l ? this.a((long)this.l, (long)var1.l) : 0;
      }
   }

   public static zh b() {
      return a(UUID.randomUUID());
   }

   private static char a(int var0) {
      var0 &= 15;
      return (char)(var0 > 9 ? var0 - 10 + 97 : var0 + 48);
   }

   private static int a(char[] var0, int var1, int var2, int var3) {
      var0[var1++] = a(var2 >> 4);
      var0[var1++] = a(var2);
      var0[var1++] = a(var3 >> 4);
      var0[var1++] = a(var3);
      return var1;
   }

   public String a(String var1) {
      if (var1 == null || var1.length() == 0) {
         var1 = "D";
      }

      int var3 = 0;
      byte var4 = 38;
      boolean var5 = true;
      if (var1.length() != 1) {
         throw new IllegalStateException("Format_InvalidGuidFormatSpecification");
      } else {
         char var6 = var1.charAt(0);
         char[] var2;
         if (var6 != 'D' && var6 != 'd') {
            if (var6 != 'N' && var6 != 'n') {
               if (var6 != 'B' && var6 != 'b') {
                  if (var6 != 'P' && var6 != 'p') {
                     throw new IllegalStateException("Format_InvalidGuidFormatSpecification");
                  }

                  var2 = new char[38];
                  var2[var3++] = '(';
                  var2[37] = ')';
               } else {
                  var2 = new char[38];
                  var2[var3++] = '{';
                  var2[37] = '}';
               }
            } else {
               var2 = new char[32];
               var4 = 32;
               var5 = false;
            }
         } else {
            var2 = new char[36];
            var4 = 36;
         }

         var3 = a(var2, var3, this.b >> 24, this.b >> 16);
         var3 = a(var2, var3, this.b >> 8, this.b);
         if (var5) {
            var2[var3++] = '-';
         }

         var3 = a(var2, var3, this.c >> 8, this.c);
         if (var5) {
            var2[var3++] = '-';
         }

         var3 = a(var2, var3, this.d >> 8, this.d);
         if (var5) {
            var2[var3++] = '-';
         }

         var3 = a(var2, var3, this.e, this.f);
         if (var5) {
            var2[var3++] = '-';
         }

         var3 = a(var2, var3, this.g, this.h);
         var3 = a(var2, var3, this.i, this.j);
         a(var2, var3, this.k, this.l);
         return new String(var2, 0, var4);
      }
   }

   // $FF: synthetic method
   public int compareTo(Object x0) {
      return this.a((zh)x0);
   }
}
